@extends('app')

@section('content')
<ul class="nav nav-tabs">
    <li ><a href="{{ url('/admin/'.$route.'/category')}}">分类列表</a></li>
    <li class="active"><a href="{{ url('/admin/'.$route.'/create?app='.$app) }}">添加分类</a></li>
</ul>

<form method="POST" action="{{ url('/admin/'.$route.'/category') }}">
    <div class="panel panel-default mt20">
        <div class="main">
        <div class="form-inline mt20">
            <div class="form-group">
                <label>分类名称：</label>
                <input type="text" class="form-control" name="cat_name" id="cat_name" @if(!empty($cate_name)) value="{{ $cate_name }}" @endif>
            </div>
        </div>
        @if($blademode == "edit")
        <input type="hidden" name="cat_id" value="{{ $cate_id }}">
        <div class="form-inline mt20">


            <div class="form-group" id="parent">
                <label>选择分类：</label>
                <select name="type" class="form-control" id="type" onchange="getChilds('category',this.value,'parent')">
                    <option value="0">主分类</option>
                    @foreach($type as $tp)
                    <option value="{{ $tp->cat_id }}" @if(($tp->cat_id == $cates->cat_id) && $up > 0) selected @endif>{{ $tp->cat_name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group ml30" id="child_1">
                @if(count($upcategory) > 0)
                    <select name="child_1" class="form-control" id="child_1" onchange="getChilds('category',this.value,child)">
                        <option value="0">请选择分类</option>
                        @foreach($upcategory as $upc)
                        <option value="{{ $upc->cat_id}}"  @if($upc->cat_id == $second_cates->cat_id ) selected @endif>{{$upc->cat_name}}</option>
                        @endforeach
                   </select>
                @endif
            </div>



        </div>
        @else
            @if(!empty($cates) && count($cates)>0)
            <div class="form-inline mt20">
                <div class="form-group" id="parent">
                    <label>上级分类：</label>
                    <select name="type" class="form-control" id="type">
                        <option value="{{ $cates->cat_id }}" selected>{{ $cates->cat_name }}</option>
                    </select>
                </div>
            </div>
            @else
            <div class="form-inline mt20">
                <div class="form-group" id="parent">
                    <label>上级分类：</label>
                    <select name="type" class="form-control" id="type" onchange="getChilds('category',this.value,'parent')">
                        <option value="0">主分类</option>
                        @foreach($type as $tp)
                        <option value="{{ $tp->cat_id }}">{{ $tp->cat_name }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="form-group ml30" id="child_1"></div>
                <div class="form-group ml30" id="child_2"></div>
                <div class="form-group ml30" id="child_3"></div>
            </div>
            @endif
        @endif
        <div class="form-inline mt20">
            <div class="form-group">
                <label>分类排序：</label>
                <input type="number" class="form-control" name="sort" id="sort" @if(isset($cate_sort)) value="{{ $cate_sort }}" @endif>
            </div>
        </div>

        {{--主页推荐--}}


        <div class="form-inline mt20">
            <div class="form-group">
                <label>栏目排序：</label>
                <input type="number" class="form-control" name="is_index" id="is_index"  min="0" max="6"@if(isset($is_index)) value="{{ $is_index }}" @endif>
                <span style="font-family: '宋体'; color:#dd1144; font-weight: 600;">默认为0为不排序</span>
            </div>
        </div>

        {{--下拉框推荐--}}
            @if(empty($second_cates)&&empty($third_cates))
        <div class="form-inline mt20">
            <div class="form-group">
                <label>下拉排序：</label>
                <input type="number" class="form-control" name="dropdown" id="dropdown"  min="0" max="6"@if(isset($dropdown)) value="{{ $dropdown }}" @endif>
                <span style="font-family: '宋体'; color:#dd1144; font-weight: 600;">默认为0为不排序</span>
            </div>
        </div>
            @endif
        <div class="form-inline mt20">
            <div class="form-group">
                <label>关&nbsp;&nbsp;键&nbsp;&nbsp;词：</label>
                <textarea rows="5" cols="20" name="identify" class="form-control">@if(isset($identify)) {{ $identify }} @endif</textarea>
            </div>
        </div>
        <div class="form-inline mt20">
            <div class="form-group">
                <label>描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述：</label>
                <textarea rows="5" cols="20" name="description" class="form-control">@if(isset($description)) {{ $description }} @endif</textarea>
            </div>
        </div>
        </div>
    </div>
    {!! csrf_field() !!}
    <input type="hidden" name="app" value="{{ $app }}" >
    <div class="form-inline mt20">
        <div class="form-group">
          <input type="submit" class="btn btn-primary btn-block" id="save" value="保存" />
        </div>
        <div class="form-group ml30">
            <input type="reset" class="btn btn-default btn-block" value="重置" />
        </div>
    </div>
</form>
@endsection
